import java.util.Vector;

public class ConfigSingleton extends java.lang.Thread{
	
	private static ConfigSingleton singleton = new ConfigSingleton( );
	
	private boolean fin = false;
	private boolean etatThread1 ;
	private boolean etatThread2;
	private boolean etatThread3;
	
	private Vector<String> images = new Vector<String>();
	
	public void run(){
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		
		while(!this.fin){
			if (this.etatThread1 == true &&  this.etatThread2 == true  && this.etatThread3 == true ){
				this.fin = true;
				waitRestart();
			}
			try {
				Thread.sleep(50);
			}catch (InterruptedException e) {
				e.printStackTrace();
			}
		}		
	}
	
	public void waitRestart(){
		while (this.fin){
			try {
				Thread.sleep(50);
			}catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		run();
	}
	
	ConfigSingleton(){
		this.etatThread1 =false;
		this.etatThread2 =false;
		this.etatThread3 =false;
	}
	
	public static ConfigSingleton getInstance(){	
		return singleton;
	}

	public Vector<String> getImages(){
		return images;
	}

	protected void setEtatThread(boolean _b, int _id){		
		if (_id == 1){	
			this.etatThread1 = _b;		
		}else if(_id == 2){
			this.etatThread2 = _b;		
		}else if(_id == 3){
			this.etatThread3 = _b;		
		}
	}
	
	protected boolean getFin(){
		return this.fin;
	}
	
	protected void setFin(){
		
		this.fin = true;
	}
	
	protected void setRestart(){
		this.fin = false;
	}
}